package spring.ioc.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/prop")
@ResponseBody
@Controller
public class ProperitiesController {
    @Value("${my.key}" )
    private  Integer mykey;

    @Value("${my.key2}" )
    private  Boolean mykey2;

    @RequestMapping("/read")
    public String readvalue(){
        return  ("读取配置文件my.key:"+mykey);
    }

    //初始化方法(可以不用打开浏览器)
    @PostConstruct
    public void  init(){
        System.out.println("mykey1"+mykey);
        System.out.println("mykey2"+mykey2);
    }
}
